package org.jing.ext.media.m3u8;

import org.jing.core.lang.annotation.SerializableField;
import org.jing.core.lang.annotation.SerializableType;
import org.jing.core.lang.data.BaseSerializableDto;
import org.jing.ext.web.Sender;

import java.net.Proxy;

/**
 * Description: <br>
 *
 * @author bksmate <br>
 * @since 2024-12-24 <br>
 */
@SerializableType
public class M3U8Config extends BaseSerializableDto {
    @SerializableField
    private int retry = 10;

    @SerializableField
    private volatile Sender sender;

    @SerializableField
    private boolean skipUnknownTags = true;

    @SerializableField
    private String relativeUrl;

    @SerializableField
    private String outputPath;

    @SerializableField
    private String fileName;

    @SerializableField
    private int threads = 10;

    @SerializableField
    private int downloadTimeout = 60 * 60;

    @SerializableField
    private boolean async = false;

    @SerializableField
    private boolean autoCombine = true;

    private M3U8Listener startListener;

    private M3U8Listener endListener;

    private M3U8MediaPartitionListener mediaPartitionStartListener;

    private M3U8MediaPartitionListener mediaPartitionSuccessListener;

    private M3U8MediaPartitionListener mediaPartitionFailListener;

    private Proxy proxy;

    public int getRetry() {
        return retry;
    }

    public void setRetry(int retry) {
        this.retry = retry;
    }

    public Sender getSender() {
        if (null == sender) {
            synchronized (this) {
                if (null == sender) {
                    sender = new Sender();
                }
            }
        }
        return sender;
    }

    public void setSender(Sender sender) {
        this.sender = sender;
    }

    public Proxy getProxy() {
        return proxy;
    }

    public void setProxy(Proxy proxy) {
        this.proxy = proxy;
    }

    public boolean isSkipUnknownTags() {
        return skipUnknownTags;
    }

    public void setSkipUnknownTags(boolean skipUnknownTags) {
        this.skipUnknownTags = skipUnknownTags;
    }

    public String getRelativeUrl() {
        return relativeUrl;
    }

    public void setRelativeUrl(String relativeUrl) {
        this.relativeUrl = relativeUrl;
    }

    public String getOutputPath() {
        return outputPath;
    }

    public void setOutputPath(String outputPath) {
        this.outputPath = outputPath;
    }

    public String getFileName() {
        return fileName;
    }

    public void setFileName(String fileName) {
        this.fileName = fileName;
    }

    public int getThreads() {
        return threads;
    }

    public void setThreads(int threads) {
        this.threads = threads;
    }

    public int getDownloadTimeout() {
        return downloadTimeout;
    }

    public void setDownloadTimeout(int downloadTimeout) {
        this.downloadTimeout = downloadTimeout;
    }

    public boolean isAsync() {
        return async;
    }

    public void setAsync(boolean async) {
        this.async = async;
    }

    public M3U8Listener getStartListener() {
        return startListener;
    }

    public void setStartListener(M3U8Listener startListener) {
        this.startListener = startListener;
    }

    public M3U8Listener getEndListener() {
        return endListener;
    }

    public void setEndListener(M3U8Listener endListener) {
        this.endListener = endListener;
    }

    public M3U8MediaPartitionListener getMediaPartitionStartListener() {
        return mediaPartitionStartListener;
    }

    public void setMediaPartitionStartListener(M3U8MediaPartitionListener mediaPartitionStartListener) {
        this.mediaPartitionStartListener = mediaPartitionStartListener;
    }

    public M3U8MediaPartitionListener getMediaPartitionSuccessListener() {
        return mediaPartitionSuccessListener;
    }

    public void setMediaPartitionSuccessListener(M3U8MediaPartitionListener mediaPartitionSuccessListener) {
        this.mediaPartitionSuccessListener = mediaPartitionSuccessListener;
    }

    public M3U8MediaPartitionListener getMediaPartitionFailListener() {
        return mediaPartitionFailListener;
    }

    public void setMediaPartitionFailListener(M3U8MediaPartitionListener mediaPartitionFailListener) {
        this.mediaPartitionFailListener = mediaPartitionFailListener;
    }

    public boolean isAutoCombine() {
        return autoCombine;
    }

    public void setAutoCombine(boolean autoCombine) {
        this.autoCombine = autoCombine;
    }
}
